#ifndef IMPORTWIDGET_H
#define IMPORTWIDGET_H
#include <QWidget>
#include "ui_importwidget.h"
#include "csvreader.h"
#include "openfilebutton.h"

#include "umsdatabase.h"

class QDomElement;
class QDomDocument;

class ImportWidget: public QWidget,Ui::ImportWidget
{
	Q_OBJECT
		CSVReader reader;
		OpenFileButton *_ofb;
		QDomElement createElement(const QString &name,const QString &value);
		QDomDocument databaseStruct();
		QString createInsert(CSVReader *rdr);
		QString cubeName();
		QString cubeNameFromReader();
		void loadFile(const QString &fname);
		QString inserts();
		QStringList insertsList();
		UMSDatabase *_dbase;
	public:
		ImportWidget();
		~ImportWidget();
		void selectFile();
		void setDatabase(UMSDatabase *dbase);		
		//QDomElement createElement(const QString &name,const QString &value);
	private slots:
		void on_editFileName_textChanged(const QString &text);
		void on_pbCreateStruct_clicked();		
		void on_pbLoad_clicked();
		
		void insertsInFile();
		void insertsInNewWindow();
		void insertsInServer(); //< отправить запросы на сервер.
	signals:
		void openQueryWindow(const QString &query);
};

#endif

